





 *** PLOT mean
 
 clear
use recs_1990
capture drop if kwh==999999

bysort moneypy: egen sumhh=total(nweight)
bysort moneypy: gen weight=nweight/sumhh
bysort moneypy: egen meankwh=total(weight*kwh)

 collapse meankwh,by(moneypy)
 
 
 *** FIGURE 4
 


*** 75/25 ratio
clear
use income_b1990.dta

forvalue i=1990/2020 {
use income_b1990.dta,clear
quietly keep if year==`i'
rename asecfwt hh_count
egen sumhh=total(hh_count)
gen weight=hh_count/sumhh
quietly sum hhincome_1990 [aweight=weight],d
quietly return list
scalar p25=r(p25)
scalar p75=r(p75)
gen ratio=p75/p25
di `i',ratio
}



clear
use income_b1990.dta

forvalue i=1990/2020 {
use income_b1990.dta,clear
quietly keep if year==`i'
rename asecfwt hh_count
egen sumhh=total(hh_count)
gen weight=hh_count/sumhh
quietly sum hhincome_1990 [aweight=weight],d
quietly return list
scalar p10=r(p10)
scalar p90=r(p90)
gen ratio=p90/p10
di `i',ratio
}

